home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / VerticalHold.sit / Vertical Hold / source code / PixelatorPlug.cpp < prev    next >
C/C++ Source or Header  |  1997-06-27  |  2KB  |  90 lines

  1. #include <LowMem.h>
  2. #include <A4Stuff.h>
  3. #include <QuickDraw.h>
  4. #include <Memory.h>
  5. #include <Resources.h>
  6. #include <Fonts.h>
  7. #include <Dialogs.h>
  8. #include <QDOffscreen.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <Timer.h>
  12.  
  13. int pixelatorPos = 1;
  14. static Boolean    growing = true;
  15. int pixelatorVal[100] =
  16. {
  17.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  18.     21, -15, 17, 18, -12, -16, 0, 0, 0, 0,
  19.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  20.     21, -15, 17, 18, -12, -16, 0, 0, 0, 0,
  21.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  22.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  23.     0, 0, 0, 0, -16, -12, 18, 17, -15, 21,
  24.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  25.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  26.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  27. };
  28.  
  29. void initPixelatorPlug()
  30. {
  31. }
  32.  
  33. void disposePixelatorPlug()
  34. {
  35. }
  36.  
  37. typedef struct {
  38.     TMTask            task;
  39.     Ptr                mainBaseAddr;
  40.     Size            worldBytes;
  41.     Ptr                worldBuffer;
  42.     short            rowBytes;
  43.     short            phase;
  44.     Rect            size;
  45.     short            offset;
  46. } MyTaskRec;
  47.  
  48. void doPixelatorPlug(MyTaskRec* myTask)
  49. {
  50.     EnterCodeResource ();
  51.     short            height = myTask -> size.bottom - myTask -> size.top;
  52.     short            phase = myTask -> phase;
  53.     short            rowBytes = myTask -> rowBytes;
  54.     Ptr                worldBuffer = myTask -> worldBuffer;
  55.     Ptr                screenBuffer = myTask -> mainBaseAddr;
  56.  
  57.     pixelatorPos+= growing ? 1 : -1;
  58.     
  59.     if(pixelatorPos > 5)
  60.     {
  61.         pixelatorPos = 5;
  62.         growing    = false;
  63.     }
  64.     if(pixelatorPos < 1)
  65.     {
  66.         pixelatorPos = 1;
  67.         growing = true;
  68.     }
  69.     
  70.     int i;
  71.     for(i = 0; i < height; i++)
  72.     {
  73.         char *j;
  74.         char *k;
  75.         
  76.         k = screenBuffer + i * rowBytes;
  77.         for(j = worldBuffer + i * rowBytes; j <= worldBuffer + i * rowBytes + rowBytes - 1 ; j+=pixelatorPos)
  78.         {
  79.             long l;
  80.             for(l = 0; l < pixelatorPos && (j+l <= worldBuffer + i * rowBytes + rowBytes - 1); l++)
  81.             {
  82.                 *k = *j;
  83.                 k++;
  84.             }
  85.         }
  86.     }
  87.     ExitCodeResource ();
  88. }
  89.  
  90.